Skip to content

feat(rust/client): add sync client - #125

Merged
OffRange merged 52 commits into
v2from
feat/sync-client
Nov 14, 2026
Merged

OffRange merged 52 commits into
v2from
feat/sync-client

Conversation

@OffRange

Copy link
Copy Markdown
Owner

No description provided.

OffRange and others added 30 commits November 9, 2026 17:40
Expose the server internals through a library target so the router and
CLI can be reached from other crates. Add a `test-support` feature that
gates the `testing` module and its optional dependencies. Drop the
dead_code expectation on `Claims::auth_time`, which the library's public
`AppState` now makes reachable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the fail-closed access token arm: a call needs a live token,
and a missing or expired one is refreshed under the AuthState mutex,
so concurrent callers share one refresh. An invalid_token refreshes
only if the generation still matches, then retries once.

The rotated refresh token is saved before the access token is kept, a
session_revoked or refresh_expired from any call ends the session, and
logout always clears local state. Header, HttpRequest and HttpResponse
stop printing header values and bodies in their Debug output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the logout could not be sent and the store could not be cleared,
a refresh token the server still accepts stayed on disk, while logout
returned a harmless looking Network error. The next call would load it
and silently restore the session.

end_session now returns the store's result. logout reports the store
failure for that double fault only; after a sent logout the entry is
dead on the server, so the send result stands. The session-revoked
paths still discard it, since the server has already killed the token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds SyncClient::step_up, stub register/login, and the keygo-e2e crate.
AuthState::replace_access keeps generation in step with access.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build the state test's token through serde, enable tokio/rt under
test-support, zeroize sha2 in keygo-api itself, move the reset doc onto
reset(), add core/sync/consumer-rules.pro, and cover the real client's
logout against the real router.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A failed save dropped the new refresh token while the store still held
the spent one, so the next refresh tripped reuse detection and signed
the user out over a transient disk error.

Following section 10 of the auth spec, the rotated session now stays in
AuthState and wins over the store until a save succeeds, and each
authenticated call writes it again. The call that hit the failure
succeeds on the new token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A review showed the refused-save tests would miss several ways of
breaking the logic, two of which bring reuse detection back. Cover
failed refreshes, a second rotation, invalid_token, a caller dropped
during the write, every sign-out path, and trusting the store again
once a retry succeeds.

Also tell TokenStore implementers that save runs under the auth lock,
and correct three comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniffi's tokio support runs on async-compat. Its multi-thread feature
keeps one slow call from blocking the others.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A macro now generates each endpoint and the route list together, so a
fixed endpoint can no longer be left out of all_routes. That makes the
source-counting every_endpoint_is_listed test unnecessary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use Method::as_str and SystemClock instead of local copies, and send
every server test request through one helper. Drop
every_endpoint_is_routed, which every_endpoint_demands_its_declared_auth
already walks the same routes for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A public key the host cannot read is now reported by the client's own
constructor, so the uniffi adapter no longer has to read it up front and
cache it. TokenStore::save borrows the session, which saves copying the
refresh token on every attempt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Split exchange into send_signed and an explicit single retry, move the
nonce copy into exchange_unlocked, and let replace_access build its own
AccessState. Stop exporting ForeignSigner. Move the duplicated client
test helpers into sync::testing, and shorten the comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Generate the callback error types with a macro, expose HttpResponse as
a remote record, and make detached a method that hands out the client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stop using OkHttp's internal HttpMethod, since POST is the only method
the API sends that requires a body, and resume the continuation from
one place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OffRange and others added 22 commits November 10, 2026 19:05
@OffRange
OffRange merged commit df10fe9 into v2 Nov 14, 2026
8 checks passed
@OffRange
OffRange deleted the feat/sync-client branch November 14, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant